package com.zjh.mybase.impl;

import com.zjh.mybase.config.SpringConfig;
import com.zjh.mybase.dao.UserDao;
import com.zjh.mybase.service.UserService;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.context.ApplicationContext;
import org.springframework.context.annotation.AnnotationConfigApplicationContext;
import org.springframework.context.annotation.ComponentScan;
import org.springframework.context.annotation.PropertySource;
import org.springframework.context.support.ClassPathXmlApplicationContext;


public class User {


    public static void main(String []args){
        //spring 加载xml 配置
      /*  ApplicationContext ctx = new ClassPathXmlApplicationContext("spring-config.xml");
        UserDao userDao = (UserDao)ctx.getBean("user");
        userDao.index();*/

        //spring 加载 注解configuration配置
        AnnotationConfigApplicationContext  ctx = new AnnotationConfigApplicationContext(SpringConfig.class);
       UserDao userDao = ctx.getBean(UserDao.class);
       userDao.index();
       System.out.println(userDao.getConfig().getVersion());
    }


}
